New String class

There is a new, more efficient implementation of class String. The new String class is compatible with the old String class except for the following:

String(char c, unsigned l =1);

is now:

String(char& c, unsigned l=1,

unsigned extra=DEFAULT_STRING_EXTRA);

The argument unsigned extra has been added to most of the String::String() constructors to allow the programmer to give a hint as to how much space to allocate in the string for additional characters. When properly used, this can reduce the number of calls made to the memory allocator.

Assignment to substrings has changed slightly. The old String class handled an assignment to a substring such as:

String s = "abcdef";

s(0,2) = "123"; // result is 12cdef

by truncating the source string to the length of the destination substring. An assignment such as:

s(0,2) = "1"; // result is 1
0cdef

would cause a null byte to be inserted in the destination substring.

The new String class replaces the target substring with the source string, adjusting the length of the target string if necessary. Thus

String s = "abcdef";

s(0,2) = "123"; // result is 123cdef

and:

s(0,2) = "1"; // result is 1cdef